import { CallNet, UserInfo, ServiceCode, GetParam } from "@/utils/public";
import { getsn, getScRstNo } from "@/utils/getsn"
import { addScRst } from "@/utils/securityProjectService"
import { addMainInfo, addTurcInfo, tsTypeNames } from "@/utils/transactService"
/**
 * 安检结果上传 
 * @param {*} SC_RST 安检结果列表（嵌套安检结果明细）
 * @param {*} callBack 成功回调函数
 */
export function uploadSecurityResult(SC_RST, callBack) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "DUTY_ID": UserInfo.DUTY_ID, //职责id
          "SC_RST": SC_RST, //安检结果信息
        },
        "SERVICE_ID": "RSC013",
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      console.log(JSON.stringify(success));
      //回调
      callBack(success);
    },
    function (error) {
      console.log(error)
    });
}
/**
 * 安检明细下载
 * @param {*} app_no 工单号
 * @param {*} callBack 成功回调
 */
export function downSecurityDetails(app_no, callBack) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "APP_NO": app_no, //任务编号
          "PAGE_NO": "1", //分页值
          "DUTY_ID": UserInfo.DUTY_ID, //职责id
          "TS_TYPE": "02", //任务类别
        },
        "SERVICE_ID": "RSC012",
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      var result = success.result;
      var data = result.DATA;
      var tsDtlList = data.TS_DTL;
      var contentValues = []; //任务明细信息列表
      var scRsts = []; //安检结果信息列表
      var scRstDtls = []; //安检结果明细信息列表
      console.log(success);
      for (var tsDtl of tsDtlList) {
        var contentValue = {};
        for (var key in tsDtl) {
          if (typeof tsDtl[key] === 'object') continue;
          contentValue[key] = tsDtl[key];
        }
        contentValues.push(contentValue);
        //安检信息结果列表处理
        if (tsDtl.SC_RST && tsDtl.SC_RST.length > 0) {
          for (var scRst of tsDtl.SC_RST) {
            var newscRst = {};
            for (var key in scRst) {
              if (typeof scRst[key] === 'object') continue;
              newscRst[key] = scRst[key];
            }
            newscRst["APP_NO"] = app_no;
            newscRst["CONS_NO"] = tsDtl.CONS_NO;
            scRsts.push(newscRst);
            //安检结果明细信息列表
            if (scRst.SC_RST_DTL && scRst.SC_RST_DTL.length > 0) {
              for (var scRstDtl of scRst.SC_RST_DTL) {
                var newscRstDtl = {};
                for (var key in scRstDtl) {
                  if (typeof scRstDtl[key] === 'object') continue;
                  newscRstDtl[key] = scRstDtl[key];
                }
                newscRstDtl["SC_PDTL_ID"] = scRst.SC_PDTL_ID;
                newscRstDtl["SC_RST_ID"] = scRst.SC_RST_ID;
                scRstDtls.push(newscRstDtl);
              }
            }
          }
        }
      }
      //将安检任务明细信息插入表
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "TS_DTL_Table",
        "contentValues": contentValues
      }), function (msg) {
        console.log(JSON.stringify(msg));
      });
      //将安检任务明细信息插入表
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "SC_RST_Table",
        "contentValues": scRsts
      }), function (msg) {
        console.log(JSON.stringify(msg));
        for (let dic of contentValues) {
          var cons_no = dic.CONS_NO;
          var app_no = dic.APP_NO;
          console.log("cons_no" + cons_no + "app_no" + app_no);
          addScRst(app_no, cons_no, function () {
            console.log("创建安检结果列表成功！");
          })

        }

      });
      //将安检任务明细信息插入表
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "SC_RST_DTL_Table",
        "contentValues": scRstDtls
      }), function (msg) {
        console.log(JSON.stringify(msg));
      });
      //套餐下载
      downPack(UserInfo.ORG_NO, UserInfo.DUTY_ID, function () {
        console.log('成功回调');
      }); //测试用需要删除
      //回调
      callBack();

    },
    function (error) {
      console.log(error)
    });

}
/**
 * 获取套餐信息，统一org_no获取的套餐信息一致，每次获取需要删除原数据
 * @param {*} org_no 单位
 * @param {*} duty_id 职责ID
 */
export function downPack(org_no, duty_id, callBack) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "ORG_NO": org_no, //任务编号
          "DUTY_ID": duty_id, //职责id
        },
        "SERVICE_ID": ServiceCode.packgeList,
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      console.log("测试测试11" + org_no);
      var result = success.result;
      var data = result.DATA;
      var packList = data.PACK_LIST;
      var materials = [];
      packList.forEach(function (pack, index) {
        pack.M_ORG_NO = org_no;
        pack.MATERIAL_LIST && pack.MATERIAL_LIST.length > 0 && pack.MATERIAL_LIST.forEach(function (material) {
          materials.push(material);
        })
      });
      // console.log("packList"+ JSON.stringify(packList));
      // console.log("materials"+ JSON.stringify(materials));
      let delMaterial = {
        "tableName": "MATERIAL_LIST ML",
        "whereClause": "LM.PACKAGE_ID IN (SELECT PL.PACKAGE_ID PACK_LIST PL WHERE PL.M_MRG_NO=?)",
        "whereArgs": [org_no]
      }
      AndroidApi.deletes(JSON.stringify({
        delMaterial
      }), function (msg) {
        let delPack = {
          "tableName": "PACK_LIST",
          "whereClause": "M_MRG_NO",
          "whereArgs": [org_no]
        }
        AndroidApi.deletes(JSON.stringify({
          delPack
        }), function (msg) {
          let count = 1;
          //将套餐信息插入表
          AndroidApi.insert(JSON.stringify({
            "tableName": "PACK_LIST",
            "contentValues": packList
          }), function (msg) {
            console.log(JSON.stringify(msg));
            //两个sql插入语句成功后执行回调
            count === 2 ? callBack() : count++;
          });
          //将套餐明细信息插入表
          AndroidApi.insert(JSON.stringify({
            "tableName": "MATERIAL_LIST",
            "contentValues": materials
          }), function (msg) {
            console.log(JSON.stringify(msg));
            //两个sql插入语句成功后执行回调
            count === 2 ? callBack() : count++;
          });
        });
      });
    },
    function (error) {
      console.log(error)
    });
}
/**
 * 获取套餐列表
 * @param {*} org_no 当前供电单位的套餐信息
 */
export function getPackList(org_no, callBack) {
  let packParam = {
    "whereClause": "SELECT PACKAGE_ID,PACKAGE_NAME name,PACKAGE_NAME ModlePrcName," +
      "PACKAGE_AMT materialPrice,PACKAGE_AMT ModlePrc,(\"份\") ModleUnitName,(\"1\") IS_PACK FROM PACK_LIST " +
      "WHERE M_ORG_NO = ? " +
      "ORDER BY ModlePrcName",
    "whereArgs": [org_no],
  }
  AndroidApi.queryTableData(JSON.stringify(packParam), function (msg) {
    console.log(msg)
    if (msg.resultCode === '9999') {
      console.log("msg.result.length" + msg.result.length);
      let count = 1;
      msg.result.length == 0 && callBack([]);
      msg.result.forEach(function (pack, index) {
        let materialParam = {
          "whereClause": "SELECT PART_NAME ModlePrcName,UNIT ModleUnit," +
            "(SELECT CODE_NAME FROM P_CODE WHERE CODE_TYPE =\"mdmPriUnit\" AND CODE_VALUE = UNIT) ModleUnitName," +
            " UNIT_PRICE ModlePrc, USE_LIMIT,PART_NO" +
            " FROM MATERIAL_LIST WHERE PACKAGE_ID = ? ORDER BY PART_NO DESC",
          "whereArgs": [pack.PACKAGE_ID],
        };
        AndroidApi.queryTableData(JSON.stringify(materialParam), function (materialMsg) {
          if (materialMsg.resultCode === '9999') {
            materialMsg.result.forEach(function (material) {
              material.isChoose = false;
              material.changeCharge = "01";
              material.amount = 0;
            });
            pack.MATERIAL_LIST = materialMsg.result;
          }
          console.log(count);
          console.log(msg.result.length)
          console.log("count == msg.result.length" + count == msg.result.length);
          count == msg.result.length ? callBack(msg.result) : count++;
        });
      });
    }
    callBack([]);
  })
}
/**
 * 下载用户档案信息
 * @param {*} appNo 工单号
 */
export function downUserInfo(consNo, successCall) {
  let count = 1;
  downUserBaseInfo(consNo, function () {
    console.log("downUserBaseInfo" + count);
    count === 2 ? successCall() : count++;
  });
  downUserAccountInfo(consNo, function () {
    console.log("downUserAccountInfo" + count);
    count === 2 ? successCall() : count++;
  });
}
function downUserBaseInfo(consNo, successCall) {
  CallNet('', '', {
    "data": {
      "SID": UserInfo.SID,
      "SN": getsn(),
      "DATA": {
        "DUTY_ID": UserInfo.DUTY_ID,
        "TS_TYPE": '99',
        "APP_NO": '', //to-do 这里需要修改成，点击download获取app_no
        "PAGE_NO": "1",
        "ORG_NO": UserInfo.ORG_NO,
        "CONS_NO": consNo
      },
      "SERVICE_ID": ServiceCode.UserInfo,
      "USER": UserInfo.USER,
      "PWD": UserInfo.PWD
    }
  },
    function (success) {
      console.log("downusersuccess", success.result.DATA);
      let data = success.result.DATA;
      //测试数据
      // let tmpdata = {"DESC":"","DATA":{"TS_RES":[{"THIS_READ_GQ":0,"ORG_NO":"10100001","MR_DIGIT":4.2,"EXCP_TYPE_CODE":"01","CONS_NO":"1017678456","THIS_YMD":"2018-07-20","MR_SN":4,"LAST_MR_NUM":0,"T_FACTOR":1,"MR_TYPE_CODE":"01","THIS_READ":0},{"THIS_READ_GQ":430,"ORG_NO":"10100001","MR_DIGIT":4.2,"EXCP_TYPE_CODE":"01","CONS_NO":"1017678456","THIS_YMD":"2018-07-20","MR_SN":4,"LAST_MR_NUM":0,"T_FACTOR":1,"MR_TYPE_CODE":"01","THIS_READ":430},{"EXCP_TYPE_CODE":"01","MR_DIGIT":0,"CONS_NO":"1017678456","THIS_YMD":"2018-07-20","ELEC_METER_READ":0,"LAST_MR_NUM":0,"MR_TYPE_CODE":"01","THIS_READ":0,"THIS_READ_GQ":0,"ORG_NO":"10100001","REMAIN_GAS":0,"MR_SN":0,"T_FACTOR":0}],"CUST_COUTRACTINFO":{},"CUST_ADDRINFO":[{"CONS_ADDR":"02区12花园一期1-1-2-202888路","CONS_STAT":"01","ORGN_CONS_NO":"","APP_NO":"0118072658266730","CONS_NO":"1017678456","PRESENT_NAME":"","CUST_NO":"119711600","SC_TYPE":"","CONS_NAME":"202","CUST_TYPE":"02","LAST_CHK_DATE":"","CUST_NAME":"202","CUST_ADDR":"02区12花园一期1-1-2-202888路","ORG_NO":"10100001","TS_TYPE":"03","GAS_NARURE":"03","USER_DOC":"0"}],"MP_INFO":[{"MP_STATUS":"02","APP_NO":"0118072658266730","CONS_NO":"1017678456","VENT_DATE":"May 1, 2018 12:00:00 AM","HAS_SRC_TYPE":"01","PRC_CODE":"10081189","MP_TYPE_CODE":"01","INST_DATE":"May 1, 2018 12:00:00 AM","CALC_MODE":"01","INST_COND_FLAG":"1","RISER_VENT_STAT":"1","RISER_VENT_DATE":"May 1, 2018 12:00:00 AM","ADDR_ID":1000000021062521,"CONS_ID":1000000017766240,"ORG_NO":"10100001","TP_FACTOR":1,"TRADE_CODE":"02","VENT_STAT":"1","TS_TYPE":"03","MR_SN":4,"GAS_NARURE":"03","MP_NO":"1000000003725162","MP_LEVEL":1,"MP_ID":1000000018637670}],"CUST_PRODINFO":[{"PROD_TYPE_NO":"0101","PROD_MODEL":"","APP_NO":"0118072658266730","CONS_NO":"1017678456","PURCHASE_TIME":"","INST_DATE":"2018-07-30 00:00:00","EQUIP_ID":1000000000000001,"FACTORY_NUMBER":"2018718004","ORG_NO":"10100001","PROD_BRAND":"","TS_TYPE":"03","PROD_BAR":"0001","MP_ID":1000000018637670}],"CERT_LIST":[{"APP_NO":"0118072658266730","EFFECT_TIME":"Jul 30, 2018 12:00:00 AM","CUST_NO":"119711600","CERT_ID":1000000000000001,"REMARK":"xxx","CARD_DATE":"Jul 30, 2018 12:00:00 AM","CERT_NUM":"421003199112012612","ORG_NO":"10100001","CERT_TYPE":"04","TS_TYPE":"03","INVALID_TIME":"Sep 30, 2022 12:00:00 AM","GIVE_CERT_ANENT":"xxx","VALID_PERIOD":50}],"BANK_LIST":[{"ORG_NO":"10100001","APP_NO":"0118072658266730","CONS_NO":"1017678456","BANK_ACCT":"2222222222221111","ACCT_ID":1000000000000027,"PRIORITY":1,"ACCOUNT_NAME":"202","TS_TYPE":"03","BANK_CODE":"B101","REMARK":"xxxxx"}],"INSU_INFO":[{"COPIES":"1","SAFE_PERIOD":"1","CONS_NO":"1017678456","INSUR_TYPE":"01","SAFE_END_DATE":"2019-07-30 23:59:59","INSUR_PROD":"01","AMT":20,"SAFE_BGN_DATE":"2018-07-31 00:00:00"}],"CUST_CONTACTINFO":[{"RELATION":"01","APP_NO":"0118072658266730","CONS_NO":"1017678456","CONT_CHANL":[{"CONT_CHANL_NO":"12345677888","PRIORITY":"1","CONS_C_CHANL_ID":1000000000000001,"CONTACT_ID":1000000000000001,"CONT_CHANL_TYPE":"01"}],"CONTACT_NAME":"202","TS_TYPE":"03","SEX":"1","CONTACT_PRIO":1,"CONTACT_ID":1000000000000001,"CONTACT_TYPE":"06"}],"NOTE_INFO":[{"BILL_TYPE":"02","VAT_ID":1000000000000001,"APP_NO":"0118072658266730","CONS_NO":"1017678456","TS_TYPE":"03","BANK_CODE":"工商银行","VAT_NAME":"王成义","VAT_ACCT":"222","VAT_NO":"1123456789","REG_ADDR":"武汉市黄陂区 15623018142","DRAW_BILL_TYPE":"01"}],"CONS_LABLEINFO":[{"UDP_FLAG":"","CONS_NO":"1017678456","LABLE_VALUE":"宠","LABLE_DESC":"1","UDP_TYPE":"","UDP_DATE":"","UDP_EMP":"","LABLE_TYPE":"01"}],"CUST_GMINFO":[{"MR_DIGIT":4.2,"APP_NO":"0118072658266730","CONS_NO":"1017678456","VENT_DATE":"2018/05/01","PRODUCE_FACT":"苍南仪表","METER_ID":1000000018319208,"THIS_MR":430,"ASSET_NO":"2018718004","PURCH_T_CAP":"","ORG_NO":"10100001","INST_LOC":"0103","TS_TYPE":"03","MR_SECT_NO":"02090001","MR_SN":4,"METER_MODEL":"LKZ-20","T_FACTOR":1,"GM_APPLY_TYPE":"01","ACCU_PURCH_GC":"","MP_ID":1000000018637670,"INTAKE_DIRE":"01"}]},"CODE":"0"};
      // data = tmpdata.DATA;
      //用户账户信息
      // console.log("以下是CUST_ACCOUNTINFO")//测试通过
      //用户账户信息，迁移到其他接口
      let CUST_ACCOUNTINFO = data.CUST_ACCOUNTINFO;
      let CUST_ADDRINFO = data.CUST_ADDRINFO;
      //联系信息
      let CUST_CONTACTINFO = data.CUST_CONTACTINFO;
      console.log('xiazia', CUST_CONTACTINFO);
      let contactInfoCVs = []; //联系信息CVs
      let contChanleCVs = []; //联系方式信息CVs
      let M_CID = getsn();
      //遍历CUST_CONTACTINFO LIST
      for (let contactInfo of CUST_CONTACTINFO) {
        //定义当次循环的联系信息CV
        let contactInfoCV = {};
        //剔除该对象内，所有为Object类型的字段----去掉JSONArray
        for (let key in contactInfo) {
          if (typeof contactInfo[key] === 'object') continue;
          contactInfoCV.M_CID = M_CID;
          contactInfoCV[key] = contactInfo[key];
        }
        //将剔除LIST以后的对象添加到联系信息CV
        contactInfoCVs.push(contactInfoCV);
        //判断对象内是否存在CONT_CHANL LIST且，该LIST长度大于0
        if (contactInfo.CONT_CHANL && contactInfo.CONT_CHANL.length > 0) {
          //遍历CONT_CHANL LIST
          for (let contChanle of contactInfo.CONT_CHANL) {
            //定义当次循环的联系方式信息CV
            let contChanleCV = {};
            //剔除该对象内，所有为Object类型的字段----去掉JSONArray
            for (let key in contChanle) {
              if (typeof contChanle[key] === 'object') continue;
              contChanleCV.M_CID = M_CID;
              contChanleCV[key] = contChanle[key];
            }
            //为该CV添加APP_NO字段，以便数据库查询关联
            contChanleCV["APP_NO"] = contactInfo.APP_NO;
            //为该CV添加CONS_NO字段，以便数据库查询关联
            contChanleCV["CONS_NO"] = contactInfo.CONS_NO;
            //添加到联系方式信息CVS
            contChanleCVs.push(contChanleCV);
          }
        }
      }

      //标签信息--暂无数据
      let CONS_LABLEINFO = data.CONS_LABLEINFO;
      //表具信息
      let CUST_GMINFO = data.CUST_GMINFO;
      //燃气设备信息
      let CUST_PRODINFO = data.CUST_PRODINFO;
      //保险信息，好像已经去掉了，先不管
      let INSU_INFO = data.INSU_INFO;
      //抄表信息
      let TS_RES = data.TS_RES;
      //供气点信息
      let MP_INFO = data.MP_INFO;
      //管线阀门信息
      let PIPE_VALVEINFO = data.PIPE_VALVEINFO;
      //证件信息
      let CERT_LIST = data.CERT_LIST;
      //银行信息
      let BANK_LIST = data.BANK_LIST;
      //开票信息
      let NOTE_INFO = data.NOTE_INFO;
      let promiseArray = [];
      promiseArray.push(new Promise(function (resolve, reject) {
        //用户地址信息
        console.log("以下是CUST_ADDRINFO");
        console.log(CUST_ADDRINFO);
        insertUserTable(CUST_ADDRINFO, "CUST_ADDRINFO", function () {
          console.log("CUST_ADDRINFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //用户联系信息
        console.log("以下是CUST_CONTACTINFO用户联系信息");
        console.log(CUST_CONTACTINFO);
        insertUserTable(contactInfoCVs, "CUST_CONTACTINFO", function () {
          console.log("CUST_CONTACTINFO-resolve");
          resolve();
        })
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //用户联系方式信息
        console.log("以下是CONT_CHANL用户联系方式信息");
        console.log("CONT_CHANL-JSON" + JSON.stringify(contChanleCVs));
        insertUserTable(contChanleCVs, "CONT_CHANL", function () {
          console.log("CONT_CHANL-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //标签信息
        console.log("以下是CONS_LABLEINFO")
        console.log(CONS_LABLEINFO);
        insertUserTable(CONS_LABLEINFO, "CONS_LABLEINFO", function () {
          console.log("CONS_LABLEINFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //表具信息
        console.log("以下是CUST_GMINFO")
        console.log(CUST_GMINFO);
        insertUserTable(CUST_GMINFO, "CUST_GMINFO", function () {
          console.log("CUST_GMINFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //燃气设备信息
        console.log("以下是CUST_PRODINFO");
        console.log(CUST_PRODINFO);
        insertUserTable(CUST_PRODINFO, "CUST_PRODINFO", function () {
          console.log("CUST_PRODINFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //保险信息
        console.log("以下是INSU_INFO");
        console.log(INSU_INFO);
        insertUserTable(INSU_INFO, "INSU_INFO", function () {
          console.log("INSU_INFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //抄表信息
        console.log("以下是TS_RES")
        console.log(TS_RES);
        insertUserTable(TS_RES, "TS_RES", function () {
          console.log("TS_RES-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //管线阀门信息
        console.log("以下是PIPE_VALVEINFO")
        console.log(PIPE_VALVEINFO);
        insertUserTable(PIPE_VALVEINFO, "PIPE_VALVEINFO", function () {
          console.log("PIPE_VALVEINFO-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //证件信息
        console.log("以下是CERT_LIST")
        console.log(CERT_LIST);
        insertUserTable(CERT_LIST, "CERT_LIST", function () {
          console.log("CERT_LIST-resolve");
          resolve();
        });
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //银行信息
        console.log("以下是BANK_LIST")
        console.log(BANK_LIST);
        insertUserTable(BANK_LIST, "BANK_LIST", function () {
          console.log("BANK_LIST-resolve");
          resolve();
        })
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //开票信息
        console.log("以下是NOTE_INFO")
        console.log(NOTE_INFO);
        insertUserTable(NOTE_INFO, "NOTE_INFO", function () {
          console.log("NOTE_INFO-resolve");
          resolve();
        })
      }));
      promiseArray.push(new Promise(function (resolve, reject) {
        //供气点信息
        console.log("以下是MP_INFO")
        console.log(MP_INFO);
        insertUserTable(MP_INFO, "MP_INFO", function () {
          console.log("MP_INFO-resolve");
          resolve();
        })
      }));
      console.log("promiseArray.length" + promiseArray.length);
      Promise.all(promiseArray).then(function () {
        console.log("所有用户信息写入成功");
        successCall();
      }).catch(function () {
        successCall();
      });
    },
    function (error) {
      successCall();
      console.log(error);
    }
  );
}
/**
 * 写入档案数据库的时候，先删除旧数据，再写入
 * @param {Array} tmpList 写入数据库的list
 * @param {String} tableName 表名
 * @param {function} callback 回调函数
 */
export function insertUserTable(tmpList, tableName, callback) {
  if (tmpList && tmpList.length > 0) {
    let promiseArray = [];
    for (let tempObj of tmpList) {
      promiseArray.push(new Promise(function (resolve, reject) {
        let deleteUser = {
          "tableName": tableName,
          "whereClause": "CONS_NO=?",
          "whereArgs": [tempObj.CONS_NO]
        }
        AndroidApi.deletes(JSON.stringify(deleteUser), function (msg) {
          resolve();
          console.log(tableName + "删除记录:" + JSON.stringify(msg));
        });
      }))
    }
    Promise.all(promiseArray).then(function () {
      AndroidApi.insert(JSON.stringify({
        "jToken": GetParam('jtoken', window),
        "tableName": tableName,
        "contentValues": tmpList
      }), function (msg) {
        console.log(msg)
        callback();
      });
    }).catch(function (msg) {
      console.log(tableName + "操作异常:" + msg);
      callback();
    });
  } else {
    callback();
  }
}
function downUserAccountInfo(consNo, successCall) {
  //用户账户信息下载接口
  CallNet('', '', {
    "data": {
      "SID": UserInfo.SID,
      "SN": getsn(),
      "DATA": {
        "DUTY_ID": UserInfo.DUTY_ID,
        "TS_TYPE": '99',
        "APP_NO": '',
        "CONS_NO": [consNo]
      },
      "SERVICE_ID": ServiceCode.UserAccount,
      "USER": UserInfo.USER,
      "PWD": UserInfo.PWD
    }
  },
    function (success) {
      console.log(success);
      let data = success.result.DATA;
      //用户账户信息
      // console.log("以下是CUST_ACCOUNTINFO")//测试通过
      let ACCOUNT_LIST = data.ACCOUNT_LIST;
      //欠费信息
      // console.log("以下是CUST_ACCOUNTINFO")//测试通过
      let OWE_LIST = data.OWE_LIST;
      //缴费明细
      // console.log("以下是CUST_ACCOUNTINFO")//测试通过
      let PAY_LIST = data.PAY_LIST;
      let promiseArray = [];

      //用户账户信息
      promiseArray.push(new Promise(function (resolve, reject) {
        //账户list
        console.log("以下是ACCOUNT_LIST")
        console.log(ACCOUNT_LIST);
        insertUserTable(ACCOUNT_LIST, "ACCOUNT_LIST", function () {
          console.log("ACCOUNT_LIST-resolve");
          resolve();
        });
      }));
      //欠费信息
      promiseArray.push(new Promise(function (resolve, reject) {
        //账户list
        console.log("OWE_LIST")
        console.log(OWE_LIST);
        insertUserTable(OWE_LIST, "OWE_LIST", function () {
          console.log("OWE_LIST-resolve");
          resolve();
        });
      }));
      //缴费明细
      promiseArray.push(new Promise(function (resolve, reject) {
        //账户list
        console.log("PAY_LIST")
        console.log(PAY_LIST);
        insertUserTable(PAY_LIST, "PAY_LIST", function () {
          console.log("PAY_LIST-resolve");
          resolve();
        });
      }));
      Promise.all(promiseArray).then(function () {
        successCall();
      }).catch(function (msg) {
        console.log("下载用户账户信息报错" + msg);
        successCall();
      });
    },
    function (error) {
      console.log(error);
    });
}

/**
 * 安检项目下载，通过用户信息的ORG_NO下载
 */
export function downSecurityProject(successCall) {
  console.log("安检项目下载");
  delSecurityProject(function () {
    console.log("执行写入安检项目下载");
    CallNet('/open/buzadapter/access/commonInvoke',
      'restApp', {
        "data": {
          "SID": UserInfo.SID,
          "SN": getsn(),
          "DATA": {
            "ORG_NO": UserInfo.ORG_NO
          },
          "SERVICE_ID": ServiceCode.SecurityProject,
          "USER": UserInfo.USER,
          "PWD": UserInfo.PWD
        }
      },
      function (success) {
        let scItems = success.result.SC_ITEM;
        let contentValues = []; //安检项目列表CV
        let scItemDtlCVs = []; //安检项目明细CV
        for (let scItem of scItems) {
          // console.log(scItem.SC_ITEM_DTL);
          let contentValue = {};
          for (let key in scItem) {
            if (typeof scItem[key] === 'object') continue;
            contentValue[key] = scItem[key];
          }
          contentValue["M_ORG_NO"] = UserInfo.ORG_NO;
          contentValues.push(contentValue);
          if (scItem.SC_ITEM_DTL && scItem.SC_ITEM_DTL.length > 0) {
            for (let scItemDtl of scItem.SC_ITEM_DTL) {
              let scItemDtlCV = {};
              for (let key in scItemDtl) {
                if (typeof scItemDtl[key] === 'object') continue;
                scItemDtlCV[key] = scItemDtl[key];
              }
              scItemDtlCV["SC_ITEM_ID"] = contentValue.SC_ITEM_ID;
              scItemDtlCVs.push(scItemDtlCV);
            }
          }
        }
        let count = 1;
        console.log(contentValues);
        AndroidApi.insert(JSON.stringify({
          "jToken": GetParam('jtoken', window),
          "tableName": "SC_ITEM",
          "contentValues": contentValues
        }), function (msg) {
          console.log("SC_ITEM插入结果")
          console.log(msg)
          console.log(count)
          count == 2 ? successCall() : count++;
          // successCall();
        });
        console.log(scItemDtlCVs);
        AndroidApi.insert(JSON.stringify({
          "jToken": "",
          "tableName": "SC_ITEM_DTL",
          "contentValues": scItemDtlCVs
        }), function (msg) {
          console.log("SC_ITEM_DTL插入结果")
          console.log(msg)
          console.log(count)
          count == 2 ? successCall() : count++;
          // successCall();
        });
      },
      function (error) {
        successCall();
        console.log(error)
      }
    );
  });

}
/**
 * 
 * @param {*} callBack 删除表成功表示
 */
function delSecurityProject(callBack) {

  let selectSecurityProject = {
    "whereClause": "select a.SC_ITEM_ID from SC_ITEM a where a.M_ORG_NO=?",
    "whereArgs": [UserInfo.ORG_NO]
  }
  AndroidApi.queryTableData(JSON.stringify(selectSecurityProject), function (msg) {
    console.log("111111111111111111111111111111111111111111111111111")
    let count = 1;
    if (msg.resultCode === '9999') {
      let result = msg.result;
      if (result && result.length > 0) {
        let sqlIn = "in (";
        for (let scItem of result) {
          sqlIn = sqlIn + scItem.SC_ITEM_ID + ","
        }
        sqlIn = sqlIn + " \"1\")";
        let delScItemDtlParam = {
          "tableName": "SC_ITEM_DTL",
          "whereClause": "SC_ITEM_ID " + sqlIn,
          "whereArgs": []
        }
        console.log("delScItemDtlParam" + JSON.stringify(delScItemDtlParam));
        AndroidApi.deletes(JSON.stringify(delScItemDtlParam), function (msg) {
          console.log("SC_ITEM_DTL删除记录:" + JSON.stringify(msg));
          console.log("count----------------------------" + count);
          count === 2 ? callBack() : count++;
        });
        AndroidApi.deletes('{"tableName": "SC_ITEM","whereClause":"M_ORG_NO=?","whereArgs":["' + UserInfo.ORG_NO + '"]}', function (msg) {
          console.log("SC_ITEM删除记录:" + JSON.stringify(msg));
          console.log("count----------------------------" + count);
          count === 2 ? callBack() : count++;
        });
      } else {
        callBack();
      }
    } else {
      callBack();
    }
  });
}

/**
 * 安检历史信息下载
 * @param {*} appNo 工单号 
 */
export function downHistorySecurity(appNo) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "DUTY_ID": UserInfo.DUTY_ID,
          "TS_TYPE": "02",
          "APP_NO": appNo, //to-do 这里需要修改成，点击download获取app_no
          "PAGE_NO": "1"
        },
        "SERVICE_ID": ServiceCode.HistorySecurity,
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      console.log("获取历史记录下载信息成功");
      console.log(appNo);
      let data = success.result.DATA;
      console.log(success.result.DATA);
      //历史安检信息下载
      let historySecurityCVs = []; //历史安检任务明细CV
      let securityResultCVs = []; //安检结果信息CV
      let securityResultDetailCVs = []; //安检结果明细信息

      let TS_DTL = data.TS_DTL;
      //处理历史安检任务明细CV
      for (let tsDtl of TS_DTL) {
        let historySecurityCV = {};
        for (let key in tsDtl) {
          if (typeof tsDtl[key] === 'object') continue;
          historySecurityCV[key] = tsDtl[key];
        }
        historySecurityCVs.push(historySecurityCV);
        if (tsDtl.SC_RST && tsDtl.SC_RST.length > 0) {
          let scRsts = tsDtl.SC_RST;
          for (let scRst of scRsts) {
            let securityResultCV = {};
            //处理安检结果信息CV
            for (let key in scRst) {
              if (typeof scRst[key] === 'object') continue;
              securityResultCV[key] = scRst[key];
            }
            securityResultCVs.push(securityResultCV);
            if (scRst.SC_RST_DTL && scRst.SC_RST_DTL.length > 0) {
              let scRstDtls = scRst.SC_RST_DTL;
              for (let scRstDtl of scRstDtls) {
                let securityResultDetailCV = {};
                //处理安检结果明细CV
                for (let key in scRstDtl) {
                  if (typeof scRstDtl[key] === 'object') continue;
                  securityResultDetailCV[key] = scRstDtl[key];
                }
                securityResultDetailCVs.push(securityResultDetailCV);
              }
            }
          }
        }
      }
      console.log(historySecurityCVs);
      console.log(securityResultCVs);
      console.log(securityResultDetailCVs);

      //这边将所有list遍历结果，并且获取对应表数据，继续执行插入sql操作
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "History_TS_DTL",
        "contentValues": historySecurityCVs
      }), function (msg) {
        console.log("历史记录插入数据成功");
        console.log("历史记录插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "History_SC_RST",
        "contentValues": securityResultCVs
      }), function (msg) {
        console.log("历史记录插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "History_SC_RST_DTL",
        "contentValues": securityResultDetailCVs
      }), function (msg) {
        console.log("历史记录插入数据成功" + JSON.stringify(msg));
      });

    },
    function (error) {
      console.log(error);
    });
}

/**
 * 获取配置信息表数据
 * @param {*} params P_CODE行 PARA_CODE列
 * @param {*} successCall 
 * @param {*} errorCall 
 */
export function getParamInfo(params, successCall, errorCall) {
  var test = params || {
    "P_CODE": 'MaterialModelPrc',
    "ORG_NO": "10100001",
    "COLUEM_INFO": [{
      "PARA_CODE": "ModlePrcName",
      "IS_P_CODE": false
    },
    {
      "PARA_CODE": "ModlePrcCode",
      "IS_P_CODE": false
    },
    {
      "PARA_CODE": "ModleUnit",
      "IS_P_CODE": true,
      "P_CODE": "mdmPriUnit"
    },
    {
      "PARA_CODE": "ModlePrc",
      "IS_P_CODE": false
    },
    ],
    "ORDER_KEY": "ModlePrcName",
    "ORDER_TYPE": "DESC"
  }
  let constSql = "SELECT "
  let paramSql = {
    "whereClause": constSql,
    "whereArgs": []
  };
  if (test.COLUEM_INFO.length <= 0) {
    errorCall("入参错误");
  }
  test.COLUEM_INFO.forEach(function (columeInfo, index) {
    constSql = constSql + " param" + index + ".PARA_VALUE " + columeInfo.PARA_CODE + ((index + 1) === test.COLUEM_INFO.length ? "" : ",");
    if (columeInfo.IS_P_CODE) {
      constSql = constSql + " (SELECT CODE_NAME FROM P_CODE WHERE CODE_TYPE = '" + columeInfo.P_CODE + "' AND CODE_VALUE = param" + "" + index + ".PARA_value) " + columeInfo.PARA_CODE + "Name" + ((index + 1) === test.COLUEM_INFO.length ? "" : ",")
    }
  });
  constSql = constSql + " FROM "
  test.COLUEM_INFO.forEach(function (columeInfo, index) {
    constSql = constSql + " param_info param" + index + ((index + 1) === test.COLUEM_INFO.length ? "" : ",");
  });
  constSql = constSql + " WHERE 1=1"
  test.COLUEM_INFO.forEach(function (columeInfo, index) {
    // constSql = constSql + " AND param" + index + ".PARA_CODE='" + columeInfo.PARA_CODE + "'";
    constSql = constSql + " AND param" + index + ".PARA_CODE=?";
    paramSql.whereArgs.push(columeInfo.PARA_CODE)
    // constSql = constSql + " AND param" + index + ".ORG_NO='" + test.ORG_NO +"' ";
    constSql = constSql + " AND param" + index + ".ORG_NO=? ";
    paramSql.whereArgs.push(test.ORG_NO)
    if (constSql.length > 0 && index > 0) {
      constSql = constSql + " AND param0.paravalue_rowid = param" + index + ".paravalue_rowid ";
    }
  });
  constSql = constSql + "AND param0.paravalue_rowid in " +
    "( select a.PARAVALUE_ROWID " +
    "from PARAM_INFO a  " +
    // "where a.P_CODE= \""+test.P_CODE+"\" and a.org_no = \"" + test.ORG_NO + "\" group by a.PARAVALUE_ROWID )";
    "where a.P_CODE= ? and a.org_no = ? group by a.PARAVALUE_ROWID )";
  paramSql.whereArgs.push(test.P_CODE)
  paramSql.whereArgs.push(test.ORG_NO)
  console.log(constSql);
  if (params.ORDER_KEY) {
    constSql = constSql + "ORDER BY " + params.ORDER_KEY + " " + params.ORDER_TYPE || "DESC"
  }

  paramSql.whereClause = constSql;
  console.log(paramSql);
  AndroidApi.queryTableData(JSON.stringify(paramSql), function (msg) {
    console.log(msg);
    if (msg.resultCode === '9999') {
      let paramResult = msg.result;
      successCall(paramResult);
    } else {
      errorCall("数据库查询失败！")
    }
  });

}

/**
 * 维修明细下载
 * @param {*} app_no 工单号
 * @param {*} callBack 成功回调
 */
export function downRepairDetails(app_no, callBack) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "APP_NO": app_no, //任务编号
          "DUTY_ID": UserInfo.DUTY_ID, //职责id
          "TS_TYPE": "03", //任务类别
        },
        "SERVICE_ID": "RSC022",
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      console.log("维修明细" + JSON.stringify(success));
      let data = success.result.DATA;
      let count = 1;
      addInstInfoCommon(data.INST_DIS_INFO, data.APP_NO, "", function () {
        //成功回调函数
        count === 5 ? callBack() : count++;
      });
      addTurcInfoCommon(data.TURC_INFO, data.APP_NO, "", function () {
        //成功回调函数
        count === 5 ? callBack() : count++;
      });
      addMainInfoCommon(data.MAIN_INFO, data.APP_NO, "", function () {
        //成功回调函数
        count === 5 ? callBack() : count++;
      });
      addRepairDetailCommon(data, function () {
        //成功回调
        count === 5 ? callBack() : count++;
      });
      addFaultCommon(data.FAULT, data.APP_NO, function () {
        //成功回调
        count === 5 ? callBack() : count++;
      });


    },
    function (error) {
    });
}
/**
 * 报停明细写入数据库（单任务的明细都用这个）
 * @param {*} result 接口返回数据list
 * @param {*} list 下载cell数据
 */
export function downTransactStop(list, callBack, errorCall) {
  let downDetail = {
    "data": {
      "SID": UserInfo.SID,
      "SN": getsn(),
      "DATA": {
        "DUTY_ID": UserInfo.DUTY_ID, //职责id
        "TS_TYPE": list.TS_TYPE, //具体任务的明细
        "APP_NO": list.APP_NO, //任务编号
      },
      "SERVICE_ID": "",
      "USER": UserInfo.USER,
      "PWD": UserInfo.PWD
    }
  }
  switch (list.TS_TYPE) {
    case "0806":
      downDetail.data.SERVICE_ID = ServiceCode.TransactStop
      break;
    case "0807":
      downDetail.data.SERVICE_ID = ServiceCode.TransactStart
      break;
    case "0818":
      downDetail.data.SERVICE_ID = ServiceCode.TransactOpen
      break;
    default: break;
  }
  console.log("downDetail")
  console.log(downDetail)
  CallNet('', '', downDetail,
    function (success) {
      console.log("adsdadas")
      console.log(success);
      //TRANSACT_TSINFO
      //_this.list
      //获取明细后将明细的APPOINT_TYPE 业务受理类型写入表，省去多建表
      if (success.resultCode === '9999') {
        let result = success.result;
        list.APPOINT_TYPE = result.DATA.APPOINT_TYPE;
        list.MAIN_STAT = "03";
        list.USER = UserInfo.USER;
        let count = 1;
        let promiseArray = [];
        promiseArray.push(new Promise(function (resolve, reject) {
          AndroidApi.insert(JSON.stringify({
            "tableName": "TRANSACT_TSINFO",
            "contentValues": [list]
          }), function (msg) {
            console.log("统一单任务下载成功" + JSON.stringify(msg))
            resolve()
          });
        }));
        promiseArray.push(new Promise(function (resolve, reject) {
          addInstInfoCommon(result.DATA.INST_DIS_INFO, list.APP_NO, list.CONS_NO, function () {
            //成功回调函数
            console.log("addInstInfoCommon");
            resolve()
          });
        }));
        promiseArray.push(new Promise(function (resolve, reject) {
          addMainInfoCommon(result.DATA.MAIN_INFO, list.APP_NO, list.CONS_NO, function () {
            //成功回调函数
            console.log("addMainInfoCommon");
            resolve();
          });
        }));
        promiseArray.push(new Promise(function (resolve, reject) {
          addTurcInfoCommon(result.DATA.TURC_INFO, list.APP_NO, list.CONS_NO, function () {
            //成功回调函数
            console.log("addTurcInfoCommon");
            resolve();
          });
        }));
        promiseArray.push(new Promise(function (resolve, reject) {
          //获取安检项目信息
          downSecurityProject(function () {
            //成功回调函数
            console.log("downSecurityProject");
            resolve()
          });
        }));
        promiseArray.push(new Promise(function (resolve, reject) {
          //获取用户信息
          console.log("下载用户信息信息信息新")
          downUserInfo(list.APP_NO, list.TS_TYPE, function () {
            //成功回调函数
            console.log("downUserInfo");
            resolve();
          });
        }));
        Promise.all(promiseArray).then(function () {
          console.log("promise 完成啦拉啦")
          callBack();
        }).catch(function (v) {
          errorCall(v);
        });
      } else {
        errorCall(success.resultMsg);
      }
    },
    function (error) {
      errorCall(error);
    }
  );
}
/**
 * 业务办理现场作业
 * @param {JSON} param 包含CONS_NO，APP_NO，TS_TYPE
 * @param {function} callback 
 */
export function uploadTransact(param, successCall, errorCall) {
  console.log("param" + JSON.stringify(param))
  let appNo = param.APP_NO || errorCall("工单号不能为空");
  let consNo = param.CONS_NO || errorCall("用户号不能为空");
  let tsType = param.TS_TYPE || errorCall("任务类型不能为空");
  console.log("tsType" + tsType)
  let mPaomise = null;
  switch (tsType) {
    case "0806":
      //报停明细上传
      mPaomise = new Promise(function (resolve, reject) {
        getTurcInfoCommon(appNo, function (result) {
          // successCall();
          CallNet('/open/buzadapter/access/commonInvoke',
            'restApp', {
              "data": {
                "SID": UserInfo.SID,
                "SN": getsn(),
                "DATA": {
                  "DUTY_ID": UserInfo.DUTY_ID,
                  "TS_TYPE": tsType,
                  "APP_NO": appNo,
                  "CONS_NO": consNo,
                  "TURC_INFO": result,
                  "INST_DIS_INFO": [],//现场拆装信息
                  "MAIN_INFO": [],//现场维修信息
                  "MATE_INFO": [],//材料信息
                  "AMT_INFO": [],//费用信息
                  "SC_RST_INFO": [],//安检结果信息
                },
                "SERVICE_ID": ServiceCode.TeansactStopUp,
                "USER": UserInfo.USER,
                "PWD": UserInfo.PWD
              }
            },
            function (success) {
              console.log("报停明细上传" + JSON.stringify(success))
              resolve();
            }, function (msg) {
              errorCall(msg)
            });
        }, function (msg) {
          errorCall(msg);
        });
      });
      break;
    default: errorCall("无此任务类别！");
  }
  //明细上传成功后，再执行工单列表的更新操作
  mPaomise.then(function () {
    console.log("132132121421s")
    let updateTransact = {
      "tableName": "TRANSACT_TSINFO",
      "whereClause": "APP_NO = ?",
      "whereArgs": [appNo],
      "contentValues": [{ "MAIN_STAT": "04" }]
    };
    AndroidApi.update(JSON.stringify(updateTransact), function (msg) {
      console.log("updatemsg" + JSON.stringify(msg))
      if (msg.resultCode === '9999') {
        successCall(tsTypeNames[tsType] + "任务上传成功！");
      } else {
        errorCall(msg.resultMsg);
      }
    });
  }).catch(function (msg) {
    console.log("catch" + msg);
    errorCall(msg);
  });
}
/**
 * 将接口获取的现场拆装list写入数据库
 * @param {*} instDisInfos 现场拆装信息List
 * @param {*} appNo 工单编号
 * @param {*} callBack 成功回调函数
 */
function addInstInfoCommon(instDisInfos, appNo, consNo, callBack) {
  let instDisInfoCVs = []; //现场拆装信息
  let mpInfoCVs = [];//供气点方案信息
  let disInfoCVs = [];//拆表信息
  let instInfoCVs = [];//装表信息
  let dveInfoCVs = [];//燃气配置信息
  let suppDveInfoCVs = [];//配套装置信息
  //现场拆装信息
  if (instDisInfos && instDisInfos.length > 0) {
    for (let instDisInfo of instDisInfos) {
      let instDisInfoCV = {};
      for (let key in instDisInfo) {
        if (typeof instDisInfo[key] === 'object') continue;
        instDisInfoCV[key] = instDisInfo[key];
      }
      instDisInfoCV["APP_NO"] = appNo;
      instDisInfoCV["CONS_NO"] = consNo;
      instDisInfoCVs.push(instDisInfoCV);
      //供气点方案信息
      if (instDisInfo.MP_INFO && instDisInfo.MP_INFO.length > 0) {
        let mpInfos = instDisInfo.MP_INFO;
        for (let mpInfo of mpInfos) {
          let mpInfoCV = {};
          for (let key in mpInfo) {
            if (typeof mpInfo[key] === 'object') continue;
            mpInfoCV[key] = mpInfo[key];
          }
          mpInfoCV["APP_NO"] = appNo;
          mpInfoCV["CONS_NO"] = consNo;
          mpInfoCVs.push(mpInfoCV);
        }
      }
      //拆表信息
      if (instDisInfo.DIS_INFO && instDisInfo.DIS_INFO.length > 0) {
        let disInfos = instDisInfo.DIS_INFO;
        for (let disInfo of disInfos) {
          let disInfoCV = {};
          for (let key in disInfo) {
            if (typeof disInfo[key] === 'object') continue;
            disInfoCV[key] = disInfo[key];
          }
          disInfoCV["APP_NO"] = appNo;
          disInfoCV["CONS_NO"] = consNo;
          disInfoCVs.push(disInfoCV);
        }
      }
      //装表信息
      if (instDisInfo.INST_INFO && instDisInfo.INST_INFO.length > 0) {
        let instInfos = instDisInfo.INST_INFO;
        for (let instInfo of instInfos) {
          let instInfoCV = {};
          for (let key in instInfo) {
            if (typeof instInfo[key] === 'object') continue;
            instInfoCV[key] = instInfo[key];
          }
          instInfoCV["APP_NO"] = appNo;
          instInfoCV["CONS_NO"] = consNo;
          instInfoCVs.push(instInfoCV);
        }
      }
      //配套配置信息
      if (instDisInfo.SUPP_DVE_INFO && instDisInfo.SUPP_DVE_INFO.length > 0) {
        let suppDveInfos = instDisInfo.SUPP_DVE_INFO;
        for (let suppDveInfo of suppDveInfos) {
          let suppDveInfoCV = {};
          for (let key in suppDveInfo) {
            if (typeof suppDveInfo[key] === 'object') continue;
            suppDveInfoCV[key] = suppDveInfo[key];
          }
          suppDveInfoCV["APP_NO"] = appNo;
          suppDveInfoCV["CONS_NO"] = consNo;
          suppDveInfoCVs.push(suppDveInfoCV);
        }
      }
      //燃气设备信息
      if (instDisInfo.DVE_INFO && instDisInfo.DVE_INFO.length > 0) {
        let dveInfos = instDisInfo.DVE_INFO;
        for (let dveInfo of dveInfos) {
          let dveInfoCV = {};
          for (let key in dveInfo) {
            if (typeof dveInfos[key] === 'object') continue;
            dveInfoCV[key] = dveInfo[key];
          }
          dveInfoCV["APP_NO"] = appNo;
          dveInfoCV["CONS_NO"] = consNo;
          dveInfoCVs.push(dveInfoCV);
        }
      }
    }
    let count = 1;
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "INST_DIS_INFO_Table",
      "contentValues": instDisInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("现场拆装插入数据成功" + JSON.stringify(msg));
    });
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "Plan_MP_INFO",
      "contentValues": mpInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("供气点方案信息插入数据成功" + JSON.stringify(msg));
    });
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "DIS_INFO_Table",
      "contentValues": disInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("拆表信息插入数据成功" + JSON.stringify(msg));
    });
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "INST_INFO_Table",
      "contentValues": instInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("装表信息插入数据成功" + JSON.stringify(msg));
    });
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "DVE_INFO_Table",
      "contentValues": dveInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("燃气设备信息插入数据成功" + JSON.stringify(msg));
    });
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "SUPP_DVE_INFO_Table",
      "contentValues": suppDveInfoCVs
    }), function (msg) {
      count === 6 ? callBack() : count++;
      console.log("配套配置信息插入数据成功" + JSON.stringify(msg));
    });
  } else {
    callBack();
  }
}
/**
 * 将接口获取的现场施工信息写入数据库
 * @param {*} turcInfos 现场施工信息list
 * @param {*} appNo 工单编号
 * @param {*} callBack 成功回调函数
 */
function addTurcInfoCommon(turcInfos, appNo, consNo, callBack) {
  let turcInfoCVs = []; //现场施工信息
  //现场施工信息
  if (turcInfos && turcInfos.length > 0) {
    for (let turcInfo of turcInfos) {
      let turcInfoCV = {};
      for (let key in turcInfo) {
        if (typeof turcInfo[key] === 'object') continue;
        turcInfoCV[key] = turcInfo[key];
      }
      turcInfoCV["APP_NO"] = appNo;
      turcInfoCV["CONS_NO"] = consNo;
      turcInfoCVs.push(turcInfoCV);
    }
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "TURC_INFO_Table",
      "contentValues": turcInfoCVs
    }), function (msg) {
      console.log("现场施工信息插入数据成功" + JSON.stringify(msg));
      callBack();

    });
  } else {
    addTurcInfo(appNo, consNo, function (msg) {
      callBack();
      console.log(msg);
    })
  }

}

/**
 * 从数据库获取施工信息，通过工单号用户号获取
 * @param {String} appNo 工单号
 * @param {String} consNo 用户号
 * @param {function} callBack 回调函数
 */
function getTurcInfoCommon(appNo, successCall, errorCall) {
  let querTurcInfoParam = {
    "jToken": "",
    "whereClause": "SELECT * FROM TURC_INFO_Table WHERE APP_NO = ? ",
    "whereArgs": [appNo]
  };
  AndroidApi.queryTableData(JSON.stringify(querTurcInfoParam), function (msg) {
    if (msg.resultCode === '9999') {
      successCall(msg.result);
    } else {
      errorCall(msg.resultMsg);
    }
  });
}
/**
 * 将接口获取的现场维修信息List写入数据库
 * @param {*} mainInfos 现场维修信息List
 * @param {*} appNo 工单编号
 * @param {*} callBack 成功回调函数
 */
function addMainInfoCommon(mainInfos, appNo, consNo, callBack) {
  let mainInfoCVs = []; //现场维修信息
  //现场维修信息
  if (mainInfos && mainInfos.length > 0) {
    for (let mainInfo of mainInfos) {
      let mainInfoCV = {};
      for (let key in mainInfo) {
        if (typeof mainInfo[key] === 'object') continue;
        mainInfoCV[key] = mainInfo[key];
      }
      mainInfoCV["APP_NO"] = appNo;
      mainInfoCV["CONS_NO"] = consNo;
      mainInfoCVs.push(mainInfoCV);
    }
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "MAIN_INFO_Table",
      "contentValues": mainInfoCVs
    }), function (msg) {
      console.log("现场维修信息插入数据成功" + JSON.stringify(msg));
      callBack();
    });
  } else {
    console.log('进入else')
    addMainInfo(appNo, consNo, function (msg) {
      console.log("callback")
      callBack();
      console.log(msg);
    })
  }

}
/**
 * 将接口的维修明细数据，写入数据库
 * @param {*} data 维修明细数据List
 * @param {*} callBack 回调函数
 */
function addRepairDetailCommon(data, callBack) {
  //维修明细信息下载
  let repairDetailCVs = []; //维修明细CV
  let repairDetailCV = {};
  for (let key in data) {
    if (typeof data[key] === 'object') continue;
    repairDetailCV[key] = data[key];
  }
  repairDetailCVs.push(repairDetailCV);
  AndroidApi.insert(JSON.stringify({
    "jToken": "",
    "tableName": "RepairDetail_Table",
    "contentValues": repairDetailCVs
  }), function (msg) {
    callBack();
    console.log("维修明细插入数据成功" + JSON.stringify(msg));
  });
}
/**
 * 将接口的故障类型List写入数据库
 * @param {*} faults 故障类型List
 * @param {*} appNo 工单编号
 */
function addFaultCommon(faults, appNo, callBack) {
  let faultCVs = []; //故障类型信息
  //故障类型信息
  if (faults && faults.length > 0) {
    for (let fault of faults) {
      let faultCV = {};
      //处理安检结果信息CV
      for (let key in fault) {
        if (typeof fault[key] === 'object') continue;
        faultCV[key] = fault[key];
      }
      faultCV["APP_NO"] = appNo;
      faultCVs.push(faultCV);
    }
    AndroidApi.insert(JSON.stringify({
      "jToken": "",
      "tableName": "RepairFault_Table",
      "contentValues": faultCVs
    }), function (msg) {
      callBack();
      console.log("维修故障类型插入数据成功" + JSON.stringify(msg));
    });
  }
}

/**
 * 维修历史信息下载
 * @param {*} appNo 工单号 
 */
export function downHistoryRepair(appNo) {
  CallNet('/open/buzadapter/access/commonInvoke',
    'restApp', {
      "data": {
        "SID": UserInfo.SID,
        "SN": getsn(),
        "DATA": {
          "DUTY_ID": UserInfo.DUTY_ID,
          "TS_TYPE": "03",
          "APP_NO": appNo, //to-do 这里需要修改成，点击download获取app_no
          "PAGE_NO": "1"
        },
        "SERVICE_ID": ServiceCode.HistoryRepair,
        "USER": UserInfo.USER,
        "PWD": UserInfo.PWD
      }
    },
    function (success) {
      console.log("获取维修历史记录下载信息成功");
      let data = success.result.DATA;
      console.log(success.result.DATA);
      data = { "DESC": "", "DATA": { "TS_RES": [{ "THIS_READ_GQ": 0, "ORG_NO": "10100001", "MR_DIGIT": 4.2, "EXCP_TYPE_CODE": "01", "CONS_NO": "1017678456", "THIS_YMD": "2018-07-20", "MR_SN": 4, "LAST_MR_NUM": 0, "T_FACTOR": 1, "MR_TYPE_CODE": "01", "THIS_READ": 0 }, { "THIS_READ_GQ": 430, "ORG_NO": "10100001", "MR_DIGIT": 4.2, "EXCP_TYPE_CODE": "01", "CONS_NO": "1017678456", "THIS_YMD": "2018-07-20", "MR_SN": 4, "LAST_MR_NUM": 0, "T_FACTOR": 1, "MR_TYPE_CODE": "01", "THIS_READ": 430 }, { "EXCP_TYPE_CODE": "01", "MR_DIGIT": 0, "CONS_NO": "1017678456", "THIS_YMD": "2018-07-20", "ELEC_METER_READ": 0, "LAST_MR_NUM": 0, "MR_TYPE_CODE": "01", "THIS_READ": 0, "THIS_READ_GQ": 0, "ORG_NO": "10100001", "REMAIN_GAS": 0, "MR_SN": 0, "T_FACTOR": 0 }], "CUST_COUTRACTINFO": {}, "CUST_ADDRINFO": [{ "CONS_ADDR": "02区12花园一期1-1-2-202888路", "CONS_STAT": "01", "ORGN_CONS_NO": "", "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "PRESENT_NAME": "", "CUST_NO": "119711600", "SC_TYPE": "", "CONS_NAME": "202", "CUST_TYPE": "02", "LAST_CHK_DATE": "", "CUST_NAME": "202", "CUST_ADDR": "02区12花园一期1-1-2-202888路", "ORG_NO": "10100001", "TS_TYPE": "03", "GAS_NARURE": "03", "USER_DOC": "0" }], "MP_INFO": [{ "MP_STATUS": "02", "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "VENT_DATE": "May 1, 2018 12:00:00 AM", "HAS_SRC_TYPE": "01", "PRC_CODE": "10081189", "MP_TYPE_CODE": "01", "INST_DATE": "May 1, 2018 12:00:00 AM", "CALC_MODE": "01", "INST_COND_FLAG": "1", "RISER_VENT_STAT": "1", "RISER_VENT_DATE": "May 1, 2018 12:00:00 AM", "ADDR_ID": 1000000021062521, "CONS_ID": 1000000017766240, "ORG_NO": "10100001", "TP_FACTOR": 1, "TRADE_CODE": "02", "VENT_STAT": "1", "TS_TYPE": "03", "MR_SN": 4, "GAS_NARURE": "03", "MP_NO": "1000000003725162", "MP_LEVEL": 1, "MP_ID": 1000000018637670 }], "CUST_PRODINFO": [{ "PROD_TYPE_NO": "0101", "PROD_MODEL": "", "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "PURCHASE_TIME": "", "INST_DATE": "2018-07-30 00:00:00", "EQUIP_ID": 1000000000000001, "FACTORY_NUMBER": "2018718004", "ORG_NO": "10100001", "PROD_BRAND": "", "TS_TYPE": "03", "PROD_BAR": "0001", "MP_ID": 1000000018637670 }], "CERT_LIST": [{ "APP_NO": "0118072658266730", "EFFECT_TIME": "Jul 30, 2018 12:00:00 AM", "CUST_NO": "119711600", "CERT_ID": 1000000000000001, "REMARK": "xxx", "CARD_DATE": "Jul 30, 2018 12:00:00 AM", "CERT_NUM": "421003199112012612", "ORG_NO": "10100001", "CERT_TYPE": "04", "TS_TYPE": "03", "INVALID_TIME": "Sep 30, 2022 12:00:00 AM", "GIVE_CERT_ANENT": "xxx", "VALID_PERIOD": 50 }], "BANK_LIST": [{ "ORG_NO": "10100001", "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "BANK_ACCT": "2222222222221111", "ACCT_ID": 1000000000000027, "PRIORITY": 1, "ACCOUNT_NAME": "202", "TS_TYPE": "03", "BANK_CODE": "B101", "REMARK": "xxxxx" }], "INSU_INFO": [{ "COPIES": "1", "SAFE_PERIOD": "1", "CONS_NO": "1017678456", "INSUR_TYPE": "01", "SAFE_END_DATE": "2019-07-30 23:59:59", "INSUR_PROD": "01", "AMT": 20, "SAFE_BGN_DATE": "2018-07-31 00:00:00" }], "CUST_CONTACTINFO": [{ "RELATION": "01", "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "CONT_CHANL": [{ "CONT_CHANL_NO": "12345677888", "PRIORITY": "1", "CONS_C_CHANL_ID": 1000000000000001, "CONTACT_ID": 1000000000000001, "CONT_CHANL_TYPE": "01" }], "CONTACT_NAME": "202", "TS_TYPE": "03", "SEX": "1", "CONTACT_PRIO": 1, "CONTACT_ID": 1000000000000001, "CONTACT_TYPE": "06" }], "NOTE_INFO": [{ "BILL_TYPE": "02", "VAT_ID": 1000000000000001, "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "TS_TYPE": "03", "BANK_CODE": "工商银行", "VAT_NAME": "王成义", "VAT_ACCT": "222", "VAT_NO": "1123456789", "REG_ADDR": "武汉市黄陂区 15623018142", "DRAW_BILL_TYPE": "01" }], "CONS_LABLEINFO": [{ "UDP_FLAG": "", "CONS_NO": "1017678456", "LABLE_VALUE": "宠", "LABLE_DESC": "1", "UDP_TYPE": "", "UDP_DATE": "", "UDP_EMP": "", "LABLE_TYPE": "01" }], "CUST_GMINFO": [{ "MR_DIGIT": 4.2, "APP_NO": "0118072658266730", "CONS_NO": "1017678456", "VENT_DATE": "2018/05/01", "PRODUCE_FACT": "苍南仪表", "METER_ID": 1000000018319208, "THIS_MR": 430, "ASSET_NO": "2018718004", "PURCH_T_CAP": "", "ORG_NO": "10100001", "INST_LOC": "0103", "TS_TYPE": "03", "MR_SECT_NO": "02090001", "MR_SN": 4, "METER_MODEL": "LKZ-20", "T_FACTOR": 1, "GM_APPLY_TYPE": "01", "ACCU_PURCH_GC": "", "MP_ID": 1000000018637670, "INTAKE_DIRE": "01" }] }, "CODE": "0" };
      //维修历史信息下载
      let historyRepairCVs = []; //历史维修任务明细CV
      let faultCVs = []; //故障类型信息
      let mainInfoCVs = []; //现场维修信息
      let instDisInfoCVs = []; //现场拆装信息
      let disInfoCVs = []; //拆表信息
      let instInfoCVs = []; //装表信息
      let dveInfoCVs = []; //燃气配置信息
      let suppDveInfoCVs = []; //配套装置信息

      let historyRepairCV = {};
      for (let key in data) {
        if (typeof data[key] === 'object') continue;
        historyRepairCV[key] = data[key];
      }
      historyRepairCVs.push(historyRepairCV);

      //现场维修信息
      if (data.MAIN_INFO && data.MAIN_INFO.length > 0) {
        let mainInfos = data.MAIN_INFO;
        for (let mainInfo of mainInfos) {
          let mainInfoCV = {};
          for (let key in mainInfo) {
            if (typeof mainInfo[key] === 'object') continue;
            mainInfoCV[key] = mainInfo[key];
          }
          mainInfoCV["APP_NO"] = data.APPO_NO;
          mainInfoCVs.push(mainInfoCV);
        }
      }
      //故障信息
      if (data.FAULT && data.FAULT.length > 0) {
        let faults = data.FAULT;
        for (let fault of faults) {
          let faultCV = {};
          //处理安检结果信息CV
          for (let key in fault) {
            if (typeof fault[key] === 'object') continue;
            faultCV[key] = fault[key];
          }
          faultCV["APP_NO"] = data.APPO_NO;
          faultCVs.push(faultCV);
        }
      }

      //现场拆装信息
      if (data.INST_DIS_INFO && data.INST_DIS_INFO.length > 0) {
        let instDisInfos = data.INST_DIS_INFO;
        for (let instDisInfo of instDisInfos) {
          let instDisInfoCV = {};
          for (let key in instDisInfo) {
            if (typeof instDisInfo[key] === 'object') continue;
            instDisInfoCV[key] = instDisInfo[key];
          }
          instDisInfoCV["APP_NO"] = data.APPO_NO;
          instDisInfoCVs.push(instDisInfoCV);
          //拆表信息
          if (instDisInfo.DIS_INFO && instDisInfo.DIS_INFO.length > 0) {
            let disInfos = instDisInfo.DIS_INFO;
            for (let disInfo of disInfos) {
              let disInfoCV = {};
              for (let key in disInfo) {
                if (typeof disInfo[key] === 'object') continue;
                disInfoCV[key] = disInfo[key];
              }
              disInfoCVs.push(disInfoCV);
            }
          }
          //装表信息
          if (instDisInfo.INST_INFO && instDisInfo.INST_INFO.length > 0) {
            let instInfos = instDisInfo.INST_INFO;
            for (let instInfo of instInfos) {
              let instInfoCV = {};
              for (let key in instInfo) {
                if (typeof instInfo[key] === 'object') continue;
                instInfoCV[key] = instInfo[key];
              }
              instInfoCVs.push(instInfoCV);
            }
          }
          //配套配置信息
          if (instDisInfo.SUPP_DVE_INFO && instDisInfo.SUPP_DVE_INFO.length > 0) {
            let suppDveInfos = instDisInfo.SUPP_DVE_INFO;
            for (let suppDveInfo of suppDveInfos) {
              let suppDveInfoCV = {};
              for (let key in suppDveInfo) {
                if (typeof suppDveInfo[key] === 'object') continue;
                suppDveInfoCV[key] = suppDveInfo[key];
              }
              suppDveInfoCVs.push(suppDveInfoCV);
            }
          }
          //燃气设备信息
          if (instDisInfo.DVE_INFO && instDisInfo.DVE_INFO.length > 0) {
            let dveInfos = instDisInfo.DVE_INFO;
            for (let dveInfo of dveInfos) {
              let dveInfoCV = {};
              for (let key in dveInfo) {
                if (typeof dveInfs[key] === 'object') continue;
                dveInfoCV[key] = dveInfo[key];
              }
              dveInfoCVs.push(dveInfoCV);
            }
          }
        }
      }

      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "History_Repair_Table",
        "contentValues": historyRepairCVs
      }), function (msg) {
        console.log("维修历史记录插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "MAIN_INFO_Table",
        "contentValues": mainInfoCVs
      }), function (msg) {
        console.log("现场维修信息插入数据成功" + JSON.stringify(msg));
        addMainInfo(appNo, function (msg) {
          console.log(msg);
          callBack();
        })
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "RepairFault_Table",
        "contentValues": faultCVs
      }), function (msg) {
        console.log("维修故障类型插入数据成功" + JSON.stringify(msg));
      });

      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "INST_DIS_INFO_Table",
        "contentValues": instDisInfoCVs
      }), function (msg) {
        console.log("现场拆装插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "DIS_INFO_Table",
        "contentValues": disInfoCVs
      }), function (msg) {
        console.log("拆表信息插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "INST_INFO_Table",
        "contentValues": instInfoCVs
      }), function (msg) {
        console.log("装表信息插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "SUPP_DVE_INFO_Table",
        "contentValues": suppDveInfoCVs
      }), function (msg) {
        console.log("配套配置信息插入数据成功" + JSON.stringify(msg));
      });
      AndroidApi.insert(JSON.stringify({
        "jToken": "",
        "tableName": "DVE_INFO_Table",
        "contentValues": dveInfoCVs
      }), function (msg) {
        console.log("燃气设备信息插入数据成功" + JSON.stringify(msg));
      });


    },
    function (error) {
      console.log(error);
    });
}

/**
 * 上传安检结果，通过app_no 和cons_no关联获取用户SC_RST(安检结果),并通过SC_RST_NO获取SC_RST_DTL(安检结果明细)
 * @param {*} app_no 
 * @param {*} cons_no 
 * @param {*} successCall 
 * @param {*} errorCall 
 */
export function uploadSecurity(app_no, cons_no, successCall, errorCall) {
  //获取安检结果信息
  //COUNT_UN_UP 待上传条数（SC_STAT 02 待下载（移动端初始下载是02，按正常情况下载成功需要改成03已下载	，但是太麻烦了，我们不改，默认02就是已下载））
  AndroidApi.queryTableData('{"jToken":"","whereClause":"select a.*,(SELECT COUNT(b.APP_NO) FROM TS_DTL_Table b WHERE b.APP_NO = a.APP_NO AND b.SC_STAT=?) COUNT_UN_UP from SC_RST_Table a  where a.APP_NO = ? AND a.CONS_NO = ?","whereArgs":["02",' + app_no + ',' + cons_no + ']}', function (msg) {
    console.log("查询安检结果记录:" + JSON.stringify(msg));
    if (msg.resultCode == 9999) {
      let SC_RST = msg.result;
      let scRstSize = SC_RST.length;
      scRstSize === 0 && successCall();
      for (let index in SC_RST) {
        let SC_RST_NO = SC_RST[index].SC_RST_NO;
        console.log("SC_RST_NO" + SC_RST_NO);
        let COUNT_UN_UP = SC_RST[index].COUNT_UN_UP;
        //获取安检结果信息
        //如果后续查询速度慢，需要加入app_no 和cons_no查询出安检明细表，通过id关联到sc_rst表，再关联SC_RST_NO
        let securityCheckParam = {
          "jToken": "",
          "whereClause": "select * from SC_RST_DTL_Table  where SC_RST_NO = ? and \"1\" = \"1\" ",
          "whereArgs": [SC_RST_NO]
        }
        AndroidApi.queryTableData(JSON.stringify(securityCheckParam), function (msg) {
          console.log("查询安检结果明细记录:" + JSON.stringify(msg));
          scRstSize--;
          if (msg.resultCode == 9999) {
            // _this.$set(SC_RST[index], "SC_RST_DTL", msg.result);
            SC_RST[index].SC_RST_DTL = msg.result;
            //调用上传接口
            console.log("123213213213213");
            console.log("msg.result" + msg.result);
            console.log(SC_RST[index]);
						/**
						 * 批量上传的时候if(COUNT_UN_UP==='1')会有问题，需要改成COUNT_UN_UP ===SC_RST.length
						 */
            //全部查询成功后，再调用上传接口
            if (scRstSize === 0) {
              uploadSecurityResult(SC_RST, function (msg) {
                if (msg.resultCode === '9999') {
                  if (msg.result.CODE === '0') {
                    AndroidApi.update('{"tableName": "TS_DTL_Table","whereClause":"APP_NO = ? AND CONS_NO = ? ","whereArgs":[' + app_no + ',"' + cons_no + '"],"contentValues":[{"SC_STAT":"04"}]}', function (msg) {
                      console.log("更新明细记录:" + JSON.stringify(msg));
                    });
                    console.log("COUNT_UN_UP" + COUNT_UN_UP);
                    if (COUNT_UN_UP === '1') {
                      // FEEDBACK(app_no,"02");//结果反馈
                      AndroidApi.update('{"tableName": "TSINFO_Table","whereClause":"APP_NO = ?","whereArgs":[' + app_no + '],"contentValues":[{"STATUS":"02"}]}', function (msg) {
                        console.log("更新工单记录:" + JSON.stringify(msg));
                      });
                    }
                    successCall();
                  } else {
                    errorCall(msg.result.DESC);
                  }
                } else {
                  errorCall(msg.resultMsg);
                }
              });
            }
          } else {
            errorCall(msg.resultMsg);
          }
        });
      }

    } else {
      _this.$vux.toast.text(msg.resultMsg);
    }
  });
}

